<template>
  <div class="s-dataCenter">
    <div class="s-dataItem">
      <DataCenterlist :data="state.queryNewCatalog" :title="'最新资源'" :moreUrl="'/DataDirectory'"></DataCenterlist>
    </div>
    <div class="s-dataItem">
      <DataCenterlist :data="state.queryApplyTop5List" :title="'热门资源'" />
    </div>
  </div>
</template>
<script setup>
import DataCenterlist from "@/components/base/DataCenterlist.vue";
import { ref, reactive, onMounted, inject } from "vue";
const http = inject("ajax");
onMounted(() => {
  getNewCatalog();
  getQueryApplyTop5();
});

let state = reactive({
  queryNewCatalog: [],
  queryApplyTop5List: [],
});

const getNewCatalog = () => {
  http("/iaiqsmde9fea569965ed56ab98ea0501752fe631902841e/queryNewCatalog", {}, "GET")
    .then(res => {
      state.queryNewCatalog = res.data;
    })
    .catch(err => {
      console.log(err.message || "数据异常");
    });
};
const getQueryApplyTop5 = async () => {
  await http("/iaiqsmde9fea569965ed56ab98ea0501752fe631902841e/queryApplyTop5", {}, "GET")
    .then(res => {
      if (res.code == 0) {
        state.queryApplyTop5List = res.data.top;
      }
    })
    .catch(err => {
      console.log(err.message || "数据异常");
    });
};
</script>
